import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description :
 * User: jiume
 * Date: 2025-04-05
 * Time: 8:57
 */
public class Test1 {
    public int longestArithSeqLength(int[] nums) {
        // 创建dp表、初始化、填表、返回值
        int n = nums.length;
        int[][] dp = new int[n][n];

        for (int i = 0; i < n; i++) {
            Arrays.fill(dp[i], 2);
        }

        int ret = 2;
        for (int i = 2; i < n; i++) {
            for (int j = 1; j < i; j++) {
                // 确定了dp[i][j]的值
                int a = 2 * nums[j] - nums[i];
                // 寻找离b最近的a
                for (int k = j - 1; k >= 0; k--) {
                    if (nums[k] == a) {
                        dp[j][i] = dp[k][j] + 1;
                        break; // 只需要找到一个即可
                    }
                }
                ret = Math.max(ret, dp[j][i]);
            }
        }

        return ret; // 这里不需要判断是否等于2
    }


    public static void main(String[] args) {
        int[] nums = {1, 2, 2, 5, 5};
        int n = nums.length;
        Map<Integer, List<Integer>> hash = new HashMap<>();
        for (int i = 0; i < n; i++) {
            List<Integer> list = hash.get(nums[i]);
            if (list == null) {
                list = new LinkedList<>();
            }
            list.add(i);
            hash.put(nums[i], list);
        }


        System.out.println("ssddsd");
    }
}
